package com.art.service.impl;

import com.art.dao.UserMapper;
import com.art.entity.User;
import com.art.service.UserService;
import com.art.utils.MybatisUtil;
import jakarta.servlet.http.HttpSession;
import org.apache.ibatis.session.SqlSession;

/**
 * IntelliJ IDEA
 *
 * @author 谭礼赞 2038940123
 * @since 2022-11-07-2022/11/7
 */

public class UserServiceImpl implements UserService {
    @Override
    public boolean auth(String uname, String pwd, HttpSession session) {
        try(SqlSession sqlSession=MybatisUtil.getSqlSession ()){
            UserMapper mapper =sqlSession.getMapper ( UserMapper.class );
            User user =mapper.getUser ( uname,pwd );
            if(user==null){
                return false;
            }
            session.setAttribute ( "user",user );
            return true;
        }
    }
}
